﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.Specialized;

namespace VectorRacer
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            var client = new Client();
            client.Players.CollectionChanged += new NotifyCollectionChangedEventHandler(Players_CollectionChanged);
            this.DataContext = client;
            client.Players.Add(new Player());
        }

        void Players_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            var players = (IList<Player>)sender;
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                foreach (var player in players)
                    _board.AddPlayer(player);
        }
    }
}
